<template>
  <div>
    <el-form :model="formData" label-width="240px"> 
      <el-form-item label='新品首发栏目商品显示数量' prop="shopping_wx_index_new">
        <el-input v-model="formData.shopping_wx_index_new"></el-input>
      </el-form-item>
      <el-form-item label="人气推荐栏目商品显示数量" prop="shopping_wx_index_hot">
        <el-input v-model="formData.shopping_wx_index_hot"></el-input>
      </el-form-item>
      <el-form-item label='品牌制造商直供栏目品牌商显示数量' prop="shopping_wx_index_brand">
        <el-input v-model="formData.shopping_wx_index_brand"></el-input>
      </el-form-item>
      <el-form-item label="专题精选栏目显示数量" prop="shopping_wx_index_topic">
        <el-input v-model="formData.shopping_wx_index_topic"></el-input>
      </el-form-item>
      <el-form-item label='分类栏目显示数量' prop="shopping_wx_catlog_list">
        <el-input v-model="formData.shopping_wx_catlog_list"></el-input>
      </el-form-item>
      <el-form-item label="分类栏目商品显示数量" prop="shopping_wx_catlog_goods">
        <el-input v-model="formData.shopping_wx_catlog_goods"></el-input>
      </el-form-item>
      <el-form-item style="display: flex;justify-content: flex-end;margin-top: 10px">
        <el-button @click="add">确定</el-button>
        <el-button @click="reset">重值</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
  
<script>
import axios from 'axios'
export default {
  name: 'shopMallHomeConfig',
  componentTitle: '商城首页配置',
  data () {
    return {
      formData:{
        shopping_wx_catlog_goods:'',	
        shopping_wx_catlog_list:'',	
        shopping_wx_index_brand:'',	
        shopping_wx_index_hot:'',	
        shopping_wx_index_new:'',	
        shopping_wx_index_topic:''	
      }
    }
  },
  methods:{
    reset(){
    this.formData=this.formData
    },
    add(){
      axios({
        url:'http://192.168.200.251:8888/admin/config/wx',
        method:'get',
        data:{
          shopping_wx_catlog_goods:this.formData.shopping_wx_catlog_goods,
          shopping_wx_catlog_list:this.formData.shopping_wx_catlog_list,
          shopping_wx_index_brand:this.formData.shopping_wx_index_brand,
          shopping_wx_index_hot:this.formData.shopping_wx_index_hot,
          shopping_wx_index_new:this.formData.shopping_wx_index_new,
          shopping_wx_index_topic:this.formData.shopping_wx_index_topic
        },
        headers:{
          'Shopping-Admin-Token': sessionStorage.getItem('Shopping-Admin-Token')
        }
      }).then(res=>{
        if(res.data.errno === 0){
          this.$notify.success({title:'修改成功'})
        }else{
          this.$notify.error({title:'修改失败'})
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.el-input{
  width: 300px
}
.el-form{
  margin-left: 100px;
}
</style>

